<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
	<title>上传文件</title>
	<%@ include file="/WEB-INF/jsp/public/common.jspf" %>
	<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/style/blue/forum.css" />
	<link type="text/css" rel="stylesheet"
	href="${pageContext.request.contextPath}/style/blue/file.css" />
<script
	src="${pageContext.request.contextPath}/script/tree/jquery.treeview.js"></script>
<script
	src="${pageContext.request.contextPath}/script/tree/jquery.cookie.js"></script>
	<script language="javascript" src="${pageContext.request.contextPath}/fckeditor/fckeditor.js" charset="utf-8"></script>
</head>
    <script type="text/javascript">	
 		 $(document).ready(function () {

 			$("#tt").change(function(){ 
 				var v=$(this).val();
 				if(v==0){
 					$("#publish").show();
 					$(".fload").hide();
 				}else{
 					$("#publish").hide();
 					$(".fload").show();
 				}
 				}) ;
 			$(function(){
 				// 指定事件处理函数
	                 $("[name=knowTypeIds]").click(function(){
 					
 					// 当选中或取消一个权限时，也同时选中或取消所有的下级权限
 					$(this).siblings("ul").find("input").prop("checked", this.checked);
 					
 					// 当选中一个权限时，也要选中所有的直接上级权限
 					if(this.checked == true){
 						$(this).parents("li").children("input").prop("checked", true);
 					}
 					
 				});
 			});
 			$(function(){
 				var fck = new FCKeditor("content");
 				fck.Width = "99%";
 				fck.Height = "500px";
 				fck.ToolbarSet = "bbs";
 				fck.BasePath = "${pageContext.request.contextPath}/fckeditor/";
 				//fck.Config['SkinPath'] = "${pageContext.request.contextPath}/scriipt/fckeditoreditor/skins/office2003/";
 				//fck.Config['SkinPath'] = "http://bbs.itcast.cn:80/widgets/fckeditor/editor/skins/office2003/";
 				fck.ReplaceTextarea();
 			});
 			

 	
		 }); 
 
 		function a(){
 			var type=document.getElementsByName("type")[0].value;
 			var password=document.getElementsByName("password")[0].value;
 			var recevieId=document.getElementsByName("recevieId")[0].value;		
 			var textname=document.getElementsByName("textname")[0].value;
 			var fileField=document.getElementsByName("fileField")[0].value;
 			if(type.length<1){
 				alert("文件类型不能为空！");
 				return false;
 			}
 			if(password.length<1){
 				alert("密码不能为空！");
 				return false;
 			}
 			if(recevieId.length<1){
 				alert("发送对象不能为空！");
 				return false;
 			}
 			if(type==0){
 				if(textname.length<1){
 					alert("文章标题不能为空！");
 	 				return false;
 				}
 			}
 			if(type==1){
 				if(fileField.length<1){
 					alert("上传附件不能为空！");
 	 				return false;
 				}
 			}
 			document.form.submit();
 			return true;
 			
 		}
	</script>  
<body>

<!-- 标题显示 --> 
<div id="Title_bar">
    <div id="Title_bar_Head">
        <div id="Title_Head"></div>
        <div id="Title"><!--页面标题-->
            <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/style/images/title_arrow.gif"/> 上传文件
        </div>
        <div id="Title_End"></div>
    </div>
</div>


<div id=MainArea>
<div style="padding-left:50px;padding-bottom:20px">
<s:select name="type" id="tt" size="1" cssClass="SelectStyle"	list="#{0:'发表文章',1:'上传附件'}" listKey="key" listValue="value" headerKey=""	headerValue="==请选文件类型=="/>
</div>

    <s:form action="rdfile_add" enctype="multipart/form-data"  target="result" name="form">
              
        <!-- 表单内容显示 -->
        <div class="ItemBlockBorder">
            <div class="ItemBlock">
                <table cellpadding="0" cellspacing="0" class="mainForm" >           
                   	<tr id="TableTitle"><td>&nbsp;&nbsp;密码</td>
                        <td>&nbsp;&nbsp;<s:password type="password" name="password" cssClass="InputStyle"/> *</td>
                    </tr>
                    <tr id="TableTitle"><td width="100">&nbsp;&nbsp;审阅者</td>
                        <td>
                        	&nbsp;&nbsp;<s:select name="recevieId" cssClass="SelectStyle"
                        		list="#operatorList" listKey="id" listValue="username"
                        		headerKey="" headerValue="==请选择审阅者=="
                        	/>
                        </td>
                    </tr>
                    
                    <tr id="TableTitle"><td>&nbsp;&nbsp;备注</td>
                        <td>&nbsp;&nbsp;<s:textarea name="remark" cssClass="TextareaStyle"></s:textarea></td>
                    </tr>
                    
                    			
                    			<tr  id="TableTitle">
								<td width="60px">设置知识类型</td>
								<td width="300px" style="padding-left: 7px;">
									<!-- 如果把全选元素的id指定为selectAll，并且有函数selectAll()，就会有错。因为有一种用法：可以直接用id引用元素 -->
									<input type="checkbox" id="cbSelectAll"
									onClick="$('[name=knowTypeIds]').attr('checked', this.checked)" />
									<label for="cbSelectAll">全选</label>
								</td>
							</tr>

							<tr id="TableTitle">
								<td width="60px"></td>
								<td>


									<ul id="tree">
										<s:iterator value="#knowTypeList">
											<li><input type="checkbox" name="knowTypeIds"
												value="${id}" 
												<s:property value="%{id in knowTypeIds ? 'checked' : ''}"/> />
												<label for="cb_${id}">${name}</label>
												<ul>
													<s:iterator value="children">
														<li><input type="checkbox" name="knowTypeIds"
															value="${id}" 
															<s:property value="%{id in knowTypeIds ? 'checked' : ''}"/> />
															<label for="cb_${id}">${name}</label>
															<ul>
												              	<s:iterator value="children">
													              	<li>
													              	<input type="checkbox" name="knowTypeIds" value="${id}" 
														         	<s:property value="%{id in knowTypeIds ? 'checked' : ''}"/> />
														        	<label for="cb_${id}">${name}</label>
													     	       </li>
													             </s:iterator>
											                	</ul>
														</li>
													</s:iterator>
												</ul>
												</li>
										</s:iterator>
									</ul>


								</td>
							</tr>
							<tr style="height: 25px;"><td>&nbsp;&nbsp;<div class="fload" style="display:none;">附件</div></td>
                    <td>&nbsp;&nbsp;<div class="fload" style="display:none;"><input  type="file" name="fileField" /></div></td>
                    </tr>
                </table>
            </div>
        </div>
        <script language="javascript">
        	$("#tree").treeview();
        </script>
        <div id="PageHead"></div>
		<center>
			
			<div id="publish" style="display:none;">
				<table border="0" cellspacing="1" cellpadding="1" width="100%" id="InputArea" >
				<tr>
						<td class="InputAreaBg" height="30" width="50px"><div class="InputTitle">标题</div></td>
						<td class="InputAreaBg"><div class="InputContent">
							<s:textfield name="textname" cssClass="InputStyle" cssStyle="text-align:center;width:250px;height:25px;font-weight:bold;color:red;font-size:20px;"/></div>
						</td>
					</tr>
					<tr height="600">
						<td class="InputAreaBg"><div class="InputTitle">内容</div></td>
						<td class="InputAreaBg" cssStyle="height:500px">
							<div class="InputContent">
								<s:textarea name="content" cssStyle="width:650px;height:500px"></s:textarea>
							</div>
						</td>
						
					</tr>					
				</table>
			</div>
		</center>
        
        <div id="InputDetailBar">
            <img src="${pageContext.request.contextPath}/style/images/save.png" onclick="a();"/>
            <a href="javascript:history.go(-1);"><img src="${pageContext.request.contextPath}/style/images/goBack.png"/></a>
        </div>
    </s:form>
</div>
<iframe name='result' style="display:none"></iframe>


</body>
</html>
